from appengine_django.models import BaseModel
from google.appengine.ext import db
import logging


# Create your models here.


class MyLink(BaseModel):
	link = db.StringProperty()
	path = db.StringProperty()
	query_path = db.StringProperty()
	comment = db.StringProperty()
	user = db.UserProperty()

def get_link_key_string( user, link ):
	return ( user.nickname() + '#' + link )
	
def get_link_key( user, link ):
	return db.Key.from_path( 'MyLink', get_link_key_string( user, link ) )
	
def get_link( user, link ):
	entry = MyLink.get_or_insert( get_link_key_string( user, link ) )
	entry.user = user
	entry.link = link
	return entry



